package ae.pcfc.etks.online.common.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * UserServiceSecurity entity. @author Mohtisham.Salahria
 */
@Entity
@Table(name = "T_ETKS_USER_SERVICE_SECURITY", schema = "ETKS_ONLINE_DBA")
@SequenceGenerator(name = "SQ_ETKS_USER_SERVICE_SECURITY", sequenceName = "SQ_ETKS_USER_SERVICE_SECURITY", initialValue = 1, allocationSize = 1)
public class UserServiceSecurity implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	// Fields

	private Long usSecurityId;
	private ServiceRole ServiceRole;
	private String usSecurityUsername;
	private String usSecurityUserType;

	// Constructors

	/** default constructor */
	public UserServiceSecurity() {
	}

	/** full constructor */
	public UserServiceSecurity(ServiceRole ServiceRole,
			String usSecurityUsername, String usSecurityUserType) {
		this.ServiceRole = ServiceRole;
		this.usSecurityUsername = usSecurityUsername;
		this.usSecurityUserType = usSecurityUserType;
	}

	// Property accessors
	@Id
	@GeneratedValue( strategy = GenerationType.SEQUENCE, generator="SQ_ETKS_USER_SERVICE_SECURITY")
	@Column(name = "US_SECURITY_ID", unique = true, nullable = false, precision = 11, scale = 0)
	public Long getUsSecurityId() {
		return this.usSecurityId;
	}

	public void setUsSecurityId(Long usSecurityId) {
		this.usSecurityId = usSecurityId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "SR_ID", nullable = false)
	public ServiceRole getServiceRole() {
		return this.ServiceRole;
	}

	public void setServiceRole(ServiceRole ServiceRole) {
		this.ServiceRole = ServiceRole;
	}

	@Column(name = "US_SECURITY_USERNAME", nullable = false, length = 50)
	public String getUsSecurityUsername() {
		return this.usSecurityUsername;
	}

	public void setUsSecurityUsername(String usSecurityUsername) {
		this.usSecurityUsername = usSecurityUsername;
	}

	@Column(name = "US_SECURITY_USER_TYPE", nullable = false, length = 1)
	public String getUsSecurityUserType() {
		return this.usSecurityUserType;
	}

	public void setUsSecurityUserType(String usSecurityUserType) {
		this.usSecurityUserType = usSecurityUserType;
	}
	@Override
	public boolean equals(Object obj) {
		// TODO Auto-generated method stub
		if(!(obj instanceof UserServiceSecurity)){
			return false;
		}
		UserServiceSecurity userServiceSecurity = (UserServiceSecurity)obj;
		if(this.getUsSecurityId().longValue() == userServiceSecurity.getUsSecurityId().longValue()){
			return true;
		}
		return super.equals(obj);	
	}
}